<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>发型工作室-忘记密码</title>
    <!-- Tell the browser to be responsive to screen width -->
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <!-- Font Awesome -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/font-awesome/css/font-awesome.min.css"/>
    <!-- Ionicons -->
    <link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css"/>
    <!-- DataTables -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/datatables/dataTables.bootstrap4.min.css"/>
    <!-- Theme style -->
    <link rel="stylesheet" href="../util/AdminLTE/dist/css/adminlte.min.css"/>
    <!-- iCheck -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/iCheck/flat/blue.css"/>
    <!-- Morris chart -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/morris/morris.css"/>
    <!-- jvectormap -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/jvectormap/jquery-jvectormap-1.2.2.css"/>
    <!-- Date Picker -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/datepicker/datepicker3.css"/>
    <!-- Daterange picker -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/daterangepicker/daterangepicker-bs3.css"/>
    <!-- bootstrap wysihtml5 - text editor -->
    <link rel="stylesheet" href="../util/AdminLTE/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.min.css"/>
    <!-- 主CSS -->
    <link rel="stylesheet" type="text/css" href="../util/css/main.css"/>
    <!-- 公共类CSS -->
    <link rel="stylesheet" type="text/css" href="../util/css/public.css"/>
</head>
<body class="hold-transition login-page">
<div class="login-box">
    <div class="login-logo">
        <a href="../../index2.html"><b>雷格</b>发型设计工作室</a>
    </div>
    <!-- /.login-logo -->
    <div class="card">
        <div class="card-body login-card-body">
            <p class="login-box-msg">密码修改</p>
			<form id="msg"  method="POST" onkeydown="if(event.keyCode==13){return false;}">
			<div class="form-group has-feedback">
                    <span class="fa fa-phone form-control-feedback"></span><samp th:text="${result}"   class="result"   style="color:red"></samp>
                    <input id="phoneNumber" name="phoneNumber" type="text" class="form-control" placeholder="手机号码" th:value="${phoneNumber}"/>
                    <input  type="button" id="btn" class="btn" style="margin-top: 20px;" value="免费获取验证码"/>
                    <samp class="result_1" th:text="${result_1}" style="float:right; margin-right: 10px; margin-top: 30px; color:red;" ></samp>
                </div>
			</form>
			<!-- 表单回车不自动提交 -->
            <form  method="post" id="ForgetPassword" onkeydown="if(event.keyCode==13){return false;}">

                <div class="form-group has-feedback">
                    <span class="fa fa-envelope form-control-feedback"></span>
                    <input name="msg" type="text" class="form-control" placeholder="验证码"/>
                </div>
                <div class="form-group has-feedback">
                    <span class="fa fa-lock form-control-feedback"></span>
                    <input id="newPassword_1" name="newPassword_1" type="password" class="form-control" placeholder="新密码"/>
                </div>
                <div class="form-group has-feedback">
                    <span class="fa fa-check form-control-feedback"></span>
                    <input id="newPassword_2" name="newPassword_2" type="password" class="form-control" placeholder="确认密码"/>
                </div>
                <div class="row">
                    <!-- /.col -->
                    <div class="col-12">
                        <button type="button" class="btn btn-primary btn-block btn-flat" id="btn2">修改密码</button>
                    </div>
                    <!-- /.col -->
                </div>
            </form>

            <div class="social-auth-links text-center mb-3">
                <!-- /.social-auth-links -->

                <p class="mb-1">
                    <a href="/login/loginAction">已有账号？点我登陆</a>
                </p>
            </div>
            <!-- /.login-card-body -->
        </div>
    </div>
</div>
<!-- /.login-box -->

<!-- jQuery -->
<script src="../util/AdminLTE/plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../util/AdminLTE/plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- iCheck -->
<script src="../util/AdminLTE/plugins/iCheck/icheck.min.js"></script>
<script>
var wait = 60;
var result;
document.getElementById("btn").onclick = function() {
	wait = 60;
    time(this);
}
document.getElementById("btn2").onclick = function() {
	ForgetPassword();
}
 function ForgetPassword(){
	 $.ajax({      
     	cache: true,  
             type: "POST",  
             url:"/login/forgotPassword",  
             data:$('#ForgetPassword').serialize(),// 你的formid  
             async: false,  
             error: function(request) {  
                 alert("Connection error:"+request.error);  
             },  
             success: function(data) {  
            	 if(data=="密码修改成功"){
            		 window.location.replace("/login/loginAction");  
            	 }else{
            		 $('.result_1').text(data);}
             	
             }  
         });  
 }
function time(o) {
    if (wait == 0) {
        o.removeAttribute("disabled");
        o.value = "免费获取验证码";
    } else {
    	if(wait==60){
            $.ajax({      
            	cache: true,  
                    type: "POST",  
                    url:"/login/sendMsg",  
                    data:$('#msg').serialize(),// 你的formid  
                    async: false,  
                    error: function(request) {  
                        alert("Connection error:"+request.error);  
                    },  
                    success: function(data) {  
                    	result = data;
                    	$('.result').text(result);
                    }  
                });  
    	}
    	if(result=="你的手机号是否已绑定"){
    		 o.removeAttribute("disabled");
    	        o.value = "免费获取验证码";
    	}else{
        o.setAttribute("disabled", true);
        o.value = wait + "秒后可以重新发送";
        wait--;
        setTimeout(function() {
            time(o)
        }, 1000)
      }
   }
}
    $(function () {
        $('input').iCheck({
            checkboxClass: 'icheckbox_square-blue',
            radioClass   : 'iradio_square-blue',
            increaseArea : '20%' // optional
        })
    })
</script>
</body>
</html>
